#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size(); int left = 0, right = n - 1;
        int max = 0, v = 0;;
        while (left < right)
        {
            v = (right - left) * min(height[left], height[right]);
            if (height[left] >= height[right]) right--;
            else left++;
            if (max < v) max = v;
        }
        return max;
    }
};
int main()
{
    Solution s;
    vector<int> v = { 1,8,6,2,5,4,8,3,7 };
    cout << s.maxArea(v);

	return 0;
}